package com.hyfrogx.modules.information.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hyfrogx.common.utils.QueryExt;
import com.hyfrogx.modules.app.form.ClientInformationVo;
import com.hyfrogx.modules.information.entity.HyInformationEntity;
import com.hyfrogx.modules.information.entity.HyInformationVerifyEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

/**
 * @author liubin
 * @date 2019/10/29 13:35
 */
@Mapper
public interface HyInformationDao extends BaseMapper<HyInformationEntity> {


  /**
   * 根据分类获取分类下所有内容和下拉随机获取数据
   * @param query
   * @param map
   * @return
   */
  List<ClientInformationVo> RandomGetInformationByContentType(QueryExt query, @Param("map") Map map);

  /**
   * 客户端获取所有推荐资讯
   * @param query
   * @param map
   * @return
   */
  List<HyInformationEntity> getallRecommendInformation(QueryExt query, @Param("map") Map map);

  List<HyInformationEntity> getallInformation(QueryExt queryExt,@Param("map") Map map);

  /**
   * 判断当前分类下是否有资源
   * @param id
   * @return
   */
  @Select("SELECT i.id,i.template_type AS templateType,i.content_type AS\n" +
    "\t\tcontentType,i.attention,i.title,i.update_time AS\n" +
    "\t\tupdateTime,i.publisher,i.create_time AS createTime,\n" +
    "\t\ti.state,c.classify,i.share_depict,i.share_img,i.approval_status,\n" +
    "\t\ti.approval_time,i.uid,i.fail_reason,i.wx_click,i.qq_click,i.wx_share_num,i.qq_share_num\n" +
    "\t\tfrom hy_information i\n" +
    "\t\tLEFT JOIN\n" +
    "\t\thy_info_classify c ON c.id =\n" +
    "\t\ti.content_type\n" +
    "\t\twhere\n" +
    "\t\t\tc.id = #{id,jdbcType=INTEGER}\n" +
    "\t\tORDER BY i.update_time DESC")
  List<HyInformationEntity> judgeInfoById(@Param("id") Integer id);
}
